<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户组管理</title>
    <?php include(APPLICATION_BASE_TPL_PATH . "/inc/include.phtml"); ?>
</head>
<body>
<div id="wrapper">
    <?php echo $menuview; ?>
	<div id="page-wrapper">
		<div class="row">
			<div class="col-lg-12">
				<button type="button" class="btn btn-primary btn-lg right add-bottom" onclick="javascript:openDialog('Modal', url('/group/editpop'));">&nbsp;&nbsp;&nbsp;新建&nbsp;&nbsp;&nbsp;</button>
				<h1 class="page-header">用户组管理</h1>
			</div>
			<!-- /.col-lg-12 -->
		</div>
		<!-- /.row -->
		<div class="row">
			<div class="col-lg-12">
				<div class="panel panel-default">
					<div class="panel-body">
						<div class="table-responsive">
							<table class="table" id="dataTables-admin">
								<thead>
								<tr>
									<th>组名</th>
									<th>描述</th>
									<th>操作</th>
								</tr>
								</thead>
								<tbody>
								<?php foreach((array)$group as $g) { ?>
									<tr>
										<td><?=$g['gname']?></td>
										<td><?=$g['description']?></td>
										<td>
											<button class="btn btn-primary btn-sm _for_view "  href="javascript:;" gid="<?php echo $g['gid']; ?>">编辑</button> |
											<a class="btn btn-primary btn-sm" href="<?=APP_ADMIN_PATH.'/group/userlist?gid='.$g['gid']?>">成员</a> |
											<a class="btn btn-primary btn-sm" href="<?=APP_ADMIN_PATH.'/acl/index?gid='.$g['gid']?>">权限</a> |
											<button class="btn btn-primary btn-sm _for_del" href="<?=APP_ADMIN_PATH.'/group/del?gid='.$g['gid']?>">删除</button>
										</td>
									</tr>
								<?php } ?>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
<script type="text/javascript">
$(document).ready(function () {
	$('#dataTables-admin').dataTable({
		"sDom": '<"top">rt<"bottom"p><"clear">',
		"iDisplayLength":20
	});

    // 编辑组
	$('._for_view').click(function(){
        openDialog('Modal', url('/group/editpop/?id='+$(this).attr('gid')));
	});

	$('._for_del').click(function(){
        if(!confirm('请确认删除？')) return;
        var self = $(this);
		$.getJSON(self.attr('href'), function(json){
			if (json.retcode == 2000000) {
				self.parent().parent().remove();
				alert('删除成功');
			} else {
				alert('删除失败');
			}
		});
	});
});
</script>
</body>

</html>



